package cn.mesmile.shiro.module.common;

import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.apache.shiro.crypto.hash.SimpleHash;

/**
 * @author zb
 * @date 2021/2/7 22:56
 * @Description:
 */
public class Md5Test {

    /**
     * 加密测试
     * @param args
     */
    public static void main(String[] args) {
        String hashName = "md5";
        String password = "123456";
        //
//        String salt2 = new SecureRandomNumberGenerator().nextBytes().toHex();
        //                                       加密方式  加密密码   盐       hash次数
        SimpleHash simpleHash = new SimpleHash(hashName, password, "aerofugia", 2);
        String s = simpleHash.toHex();
        System.out.println("s = " + s);
        System.out.println("simpleHash = " + simpleHash);

        //内部使用MessageDigest
        SimpleHash sha1 = new SimpleHash("SHA-1", password, "aerofugia", 2);
        System.out.println("sha1 = " + sha1);

        //内部使用MessageDigest
        SimpleHash sha_256 = new SimpleHash("SHA-256", password, "aerofugia", 2);
        System.out.println("sha_256 = " + sha_256);

        //内部使用MessageDigest
        SimpleHash sha_512 = new SimpleHash("SHA-512", password, "aerofugia", 2);
        System.out.println("sha_512 = " + sha_512);


    }
}
